package com.ui;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UnsupportedLookAndFeelException;

public class Demo extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Demo app;
	public Demo() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
	{
		this.setTitle("Demo...");
		JLabel lbl = new JLabel("Demo.. Please contact our technical support.");
		lbl.setHorizontalAlignment(SwingConstants.CENTER);
		lbl.setOpaque(true);
		Container cnt = this.getContentPane();
		cnt.setLayout(new BorderLayout());
		JPanel pane = new JPanel();
		pane.setLayout(new BorderLayout());
		pane.add(lbl);
		cnt.add(pane,BorderLayout.CENTER);
		this.setUndecorated(true);
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		this.setPreferredSize(new Dimension(300,80));
		this.setAlwaysOnTop(true);
		moveToCenter();
	}
	
	private void moveToCenter()
	{
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation((screen.width-this.getWidth())/2, (screen.height- this.getHeight())/2);
	}
	
	public static void showDemo() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
	{
		if(app==null)
			app=new Demo();
		app.setVisible(true);
		SwingUtilities.invokeLater(new Runnable(){
			public void run()
			{
				app.pack();
			}
		});
	}
}
